package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Virtual;
import com.example.demo.jooq.tables.pojos.Vps;
import com.example.demo.model.request.VirtualPageRequest;
import com.example.demo.model.request.VirtualRequest;
import com.example.demo.model.response.VirtualResponse;
import com.example.demo.model.response.VisaResponse;
import com.example.demo.service.order.IOrderService;
import com.example.demo.service.order.IVirtualService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/virtual/")
public class VirtualController {
    @Autowired
    private IVirtualService iVirtualService;
    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<VirtualResponse>> queryPageVirtualList(VirtualPageRequest virtualPageRequest) {
        return iVirtualService.queryPageVirtualList(virtualPageRequest);
    }
    /**
     * 保存virtual
     * @param virtual 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveVps(@RequestBody VirtualRequest virtual) {
        return iVirtualService.saveVirtual(virtual);
    }

    /**
     * 查询虚拟机详情
     * @param virtualId 主键id
     * @return
     */
    @GetMapping(value = "detail")
    public ResultObject<VirtualResponse>  queryOneCard(@RequestParam("virtualId") String virtualId) {
        return iVirtualService.queryVirtuaDetail(virtualId);
    }
}
